Restart wireguard VPN client
This is a guide how you restart a wireguard VPN client on an ASUS router running Asuswrt-Merlin automatically, 10 seconds after boot of the router
Create and configure the services-start script to run your custom script with a 10-second delay:
- Connect to your router via SSH
- Navigate to the
/jffs/scriptsdirectory:cd /jffs/scripts - Create a new script called
services-startusing thevitext editor (you can also usenanoif it’s available on your router):vi services-start - Press “i” to enter insert mode in
vi, and add the following lines to the script:#!/bin/sh(sleep 10 && /jffs/scripts/restart_wireguard_client.sh) & - Save the changes and exit
viby pressing the “Esc” key, then typing:wqand pressing “Enter”. - Make the
services-startscript executable:chmod +x services-start - Create your script in the
/jffs/scriptsdirectory:vi restart_wireguard_client.sh - Press “i” to enter insert mode in
vi, and add your script content. - Put this into the script:
!/bin/sh
service restart_wgc - Save the changes and exit
vias described in step 5. - Make your script executable:
chmod +xrestart_wireguard_client.sh - Close the SSH connection by typing
exitand pressing “Enter”.
Now, when your router boots up and all services have started, the services-start script will be executed, which in turn will run your restart_wireguard_client.sh script after a 10-second delay.
